﻿using System;
using System.Configuration;

namespace Catalyst.Configuration
{
	public class SpecializedTableElementCollection<ItemType, ListType> : ConfigurationElementCollection
		where ItemType : SpecializedTableElement<ItemType>, new()
		where ListType : SpecializedTableElementCollection<ItemType, ListType>, new()
	{
		protected override ConfigurationElement CreateNewElement()
		{
			return new ItemType();
		}

		protected override object GetElementKey(ConfigurationElement element)
		{
			return ((ItemType)element).Name;
		}
	}

	public abstract class SpecializedTableElement<ItemType> : ConfigurationElement
		where ItemType : SpecializedTableElement<ItemType>, new()
	{
		[ConfigurationProperty("name", IsRequired = true)]
		public string Name
		{
			get { return this["name"].ToString(); }
		}
	}
}
